<?php

class Default_Model_Reading extends Zend_Db_Table{
	
	protected $_name    = "reading";
	protected $_primary  = "r_id"; 
	protected $_listSQL;
	
	public function listItems($params = null, $fields = null){
		$db 	= $this->getAdapter();
		if($fields == null) 
			$select = $db->select()->from($this->_name);
		else
			$select = $db->select()->from($this->_name, $fields);
		
		
		if($params['cid'] != null && $params['cid'] >0){
			$notinid = "";
			for ($i = 1; $i <= $params['cid']; $i++) {
				$notinid =   $i. "," .$notinid;
			}
			$notinid = substr($notinid,0,-1);
			$select->where('r_dataversion_id NOT IN ('.$notinid.')');
		}
		$result = $db->fetchAll($select);
		return $result;
	}
}